<template>
    <page-body>
        <view class="page">
            <view class="flex align-stretch benben-position-layout flex result_flex_0" :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
                <view class='flex align-center flex-sub result_fd0_0'>
                    <view class='flex align-center result_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
                        <text class='fu-iconfont2  result_fd0_0_c0_c0'>&#xE794;</text>
                    </view>
                    <view class='flex align-center result_fd0_0_c1'>
                        <image class='result_fd0_0_c1_c0' mode="aspectFit" @tap.stop="sousuo" :src='STATIC_URL+"14.png"'></image>
                        <benben-input class='flex-sub result_fd0_0_c1_c1' type="text"  :placeholder="`请输入关键词`" confirm-type="done" :maxlength="200" 
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:28rpx" v-model="keyword" @confirm="sousuo"/>
                        <image class='result_fd0_0_c1_c2' mode="aspectFit" v-if="keyword" :src='STATIC_URL+"48.png"' @tap.stop="cleanKeywordFunc()"></image>
                    </view>
                </view>

            </view>
            <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
            <view class="flex flex-direction align-stretch justify-center benben-position-layout flex result_flex_1" :style="{top:(88+StatusBarRpx)+'rpx', }">
                <view class='flex align-center self-center justify-between flex-sub result_fd1_0'>
                    <view class='flex align-center result_fd1_0_c0' @tap.stop="switchComprehensiveFunc()">
                        <text class='result_fd1_0_c0_c0' v-if="sort_field!='1'">综合排序</text><text class='result_fd1_0_c0_c0_1' v-if="sort_field=='1'">综合排序</text>
                        <image class='result_fd1_0_c0_c1' mode="aspectFit" :src='STATIC_URL+"17.png"'></image>
                    </view>
                    <view class='flex align-center result_fd1_0_c0' @tap.stop="switchShopListFunc(2)" v-if="showId=='1'">
                        <text class='result_fd1_0_c1_c0' v-if="sort_field!='2'">评分</text><text class='result_fd1_0_c1_c0_1' v-if="sort_field=='2'">评分</text>
                        <image class='result_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"18.png"' v-if="sort_field!='2'"></image>
                        <image class='result_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"19.png"' v-if="sort_field=='2' && sort_type=='desc'"></image>
                        <image class='result_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"20.png"' v-if="sort_field=='2' && sort_type=='asc'"></image>
                    </view>
                    <view class='flex align-center result_fd1_0_c0' @tap.stop="switchShopListFunc(3)" v-if="showId=='1'">
                        <text class='result_fd1_0_c1_c0' v-if="sort_field!='3'">收藏</text><text class='result_fd1_0_c2_c0_1' v-if="sort_field=='3'">收藏</text>
                        <image class='result_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"18.png"' v-if="sort_field!='3'"></image>
                        <image class='result_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"19.png"' v-if="sort_field=='3' && sort_type=='desc'"></image>
                        <image class='result_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"20.png"' v-if="sort_field=='3' && sort_type=='asc'"></image>
                    </view>
                    <view class='flex align-center result_fd1_0_c0' @tap.stop="switchShopListFunc(4)" v-if="showId=='1'">
                        <text class='result_fd1_0_c1_c0' v-if="sort_field!='4'">人均价格</text><text class='result_fd1_0_c2_c0_1' v-if="sort_field=='4'">人均价格</text>
                        <image class='result_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"18.png"' v-if="sort_field!='4'"></image>
                        <image class='result_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"19.png"' v-if="sort_field=='4' && sort_type=='desc'"></image>
                        <image class='result_fd1_0_c1_c1' mode="aspectFit" :src='STATIC_URL+"20.png"' v-if="sort_field=='4' && sort_type=='asc'"></image>
                    </view>
                </view>

            </view>
            <view :style="{height: '90rpx'}"></view>
            <!---flex布局flex布局开始-->
            <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout result_flex_2">
                <template v-for='(item,key0) in list'>
                    <view class='flex flex-wrap align-start result_fd2_0' @tap.stop="handleJumpDiy" data-type="navigateTo" 
					:data-url="`/pages/inSchool/dpDetails/dpDetails?aid=${item.aid}`" :key='key0'>
                        <image class='result_fd2_0_c0' mode="aspectFill" :src='item.logo'></image>
                        <view class='flex flex-direction flex-wrap align-stretch flex-sub'>
                            <text class='result_fd2_0_c1_c0'>{{item.name}}</text>
                            <view class='flex flex-wrap align-center result_fd2_0_c1_c1'>
                                <image class='result_fd2_0_c1_c1_c0' mode="aspectFit" :src='STATIC_URL+"22.png"'></image>
                                <text class='result_fd2_0_c1_c1_c1'>{{item.score}}</text>
                                <text class='result_fd2_0_c1_c1_c2'>月售</text>
                                <text class='result_fd2_0_c1_c1_c3'>{{item.month_sale_num}}</text>
                                <text class='result_fd2_0_c1_c1_c4'>人均￥</text>
                                <text class='result_fd2_0_c1_c1_c3'>{{item.per_capita}}</text>
                            </view>
                            <view class='flex flex-wrap align-center result_fd2_0_c1_c2' v-if="item.coupon_list.length > 0">
								<template v-for='(child,key1) in item.coupon_list'>
									<view class='flex flex-wrap align-center result_fd2_0_c1_c2_c0'>
										<text class='result_fd2_0_c1_c2_c0_c0'>{{child.name}}</text>
									</view>
								</template>
                            </view>

                            <scroll-view class='result_fd2_0_c1_c3' :scroll-x='true' :scroll-y='true' :show-scrollbar='true'>
                                <view class='flex benben-scroll flex align-center'>
                                    <template v-for='(child,key1) in item.goods_list'>
                                        <view class='flex flex-direction flex-wrap align-stretch result_fd2_0_c1_c2' @tap.stop="handleJumpDiy" data-type="navigateTo" 
										:data-url="`/pages/inSchool/spDetails/spDetails?aid=${child.aid}&sid=${item.aid}`" :key='key1'>
                                            <image class='result_fd2_0_c1_c3_c0_c0' mode="aspectFill" :src='child.thumb'></image>
                                            <text class='result_fd2_0_c1_c3_c0_c1'>{{child.name}}</text>
                                            <view class='flex flex-wrap align-center result_fd2_0_c1_c3_c0_c2'>
                                                <text class='result_fd2_0_c1_c3_c0_c2_c0'>￥</text>
                                                <text class='result_fd2_0_c1_c3_c0_c2_c0'>{{child.shop_price}}</text>
                                                <text class='result_fd2_0_c1_c3_c0_c2_c2'>￥</text>
                                                <text class='result_fd2_0_c1_c3_c0_c2_c3'>{{child.market_price}}</text>
                                            </view>
                                        </view>
                                    </template>

                                </view>
                            </scroll-view>

                        </view>
                    </view>
                </template>
                <fu-empty :pagingListLoadedAll="pagingListLoadedAll" :pagingListNoListData="pagingListNoListData" :listDataLength="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
            </view>

            <!---flex布局flex布局结束-->


        </view>
    </page-body>
</template>
<script>
    import pagingList from '@/common/mixin/paging_list.js';
    import {
        validate
    } from '@/common/utils/validate.js'

    export default {
        components: {},
        mixins: [pagingList],

        data() {
            return {
                "minixPagingListsApi": "",
                "pageingListApiMethod": "",
                "allowOnloadGetList": false,
                "sort_field": "1",
                "sort_type": "desc",
                "showId": "1",
                "keyword": "",
                "list": [],
				xuexiao:'',
            };
        },
        computed: {

        },
        watch: {},
        onLoad(options) {
            let {
                keyword
            } = options
            if (keyword !== undefined) this.keyword = keyword
			if (uni.getStorageSync('schooLinfo')) {
				console.log(uni.getStorageSync('schooLinfo'))
				this.xuexiao = JSON.parse(uni.getStorageSync('schooLinfo'))
			}
        },
        onUnload() {

        },
        onReady() {

        },
        onShow() {
            this.getxc46b1f30e49eeFunc()
        },
        onHide() {

        },
        onResize() {

        },
        onPullDownRefresh() {

        },
        onReachBottom(e) {

        },
        onPageScroll(e) {

        },
        methods: {
			sousuo(){
				if(this.keyword){
					this.$store.commit('appSearchHistoryAdd', {
					    "name": this.keyword
					})
				}
				
				this.getxc46b1f30e49eeFunc()
			},
            //清空关键词
            cleanKeywordFunc() {
                this.keyword = this.keyword;
                this.keyword = '';
				this.getxc46b1f30e49eeFunc()
            },
            //切换商品排序
            switchShopListFunc(type) {
                this.sort_field = type;
                if (this.sort_type == 'desc') {
                    this.sort_type = 'asc';
                } else {
                    this.sort_type = 'desc';
                }
                this.showId = '1';
				this.getxc46b1f30e49eeFunc()
            },
            //综合切换
            switchComprehensiveFunc() {
                this.sort_field = '1';
                this.showId = '1';
				this.getxc46b1f30e49eeFunc()
            },
            //顶部搜索
            topSearchFunc() {
                this.$store.commit('appSearchHistoryAdd', {
                    "name": this.keyword
                })
				this.getxc46b1f30e49eeFunc()
                // if (this.showId == '1') {

                // } else {

                // }
            },
            //首页搜索
            getxc46b1f30e49eeFunc() {
				let page = {
					school_id:this.xuexiao.aid,
					keyword:this.keyword,
				}
				if(this.sort_field == 1){
					page.field = 'synthesis'
				}else if(this.sort_field == 2){
					page.field = 'good'
					page.sort_type = this.sort_type
				} else if(this.sort_field == 3){
					page.field = 'collection'
					page.sort_type = this.sort_type
				}else if(this.sort_field == 4){
					page.field = 'price'
					page.sort_type = this.sort_type
				}
				
                this.minixPagingListsApi = global.apiUrls.post646b1f30e49ee;
                this.pageingListApiMethod = 'get';
                this.allowOnloadGetList = false;
                this.pagingListPostDataContent = page
                this.listData = [];
                this.list = this.listData;
                this.pagingListToggle();

            },
            pagingListPostData() {
                return this.pagingListPostDataContent
            }
        }
    };
</script>
<style lang="scss" scoped>
    .page {
        width: 100vw;
        overflow-x: hidden;
        min-height: calc(100vh - var(--window-bottom));
        background: var(--benbenbgColor2);
        background-size: 100% auto;
    }

    .result_flex_0 {
        background: #fff;
        width: 750rpx;
        height: 88rpx;
        overflow: hidden;
        z-index: 10;
        top: 0rpx;
        background-size: 100% auto !important;
    }

    .result_fd0_0_c1_c2 {
        width: 32rpx;
        height: 32rpx;
    }

    .result_fd0_0_c1_c1 {
        font-size: 28rpx;
        font-weight: 400;
        color: var(--benbenFontColor0);
        margin: 0rpx 20rpx 0rpx 0rpx;
    }

    .result_fd0_0_c1_c0 {
        width: 28rpx;
        height: 28rpx;
        margin: 0rpx 16rpx 0rpx 0rpx;
    }

    .result_fd0_0_c1 {
        background: #F6F7F9;
        height: 64rpx;
        border-radius: 32rpx 32rpx 32rpx 32rpx;
        padding: 0rpx 24rpx 0rpx 24rpx;
        margin: 0rpx 0rpx 0rpx 24rpx;
        width: 400rpx;
    }

    .result_fd0_0_c0_c0 {
        font-size: 36rpx;
        font-weight: 500;
        color: #333;
    }

    .result_fd0_0_c0 {
        height: 88rpx;
    }

    .result_fd0_0 {
        padding: 0rpx 32rpx 0rpx 32rpx;
        height: 88rpx;
    }

    .result_flex_1 {
        background: #fff;
        width: 750rpx;
        height: 90rpx;
        overflow: hidden;
        z-index: 10;
        top: 88rpx;
        background-size: 100% auto !important;
    }

    .result_fd1_0_c2_c0_1 {
        color: var(--benbenFontColor4);
        font-size: 32rpx;
        font-weight: 400;
        line-height: 45rpx;
        margin: 0rpx 10rpx 0rpx 0rpx;
    }

    .result_fd1_0_c1_c1 {
        width: 10rpx;
        height: 18rpx;
        border-radius: 0rpx 0rpx 0rpx 0rpx;
    }

    .result_fd1_0_c1_c0_1 {
        font-size: 32rpx;
        font-weight: 400;
        line-height: 45rpx;
        margin: 0rpx 10rpx 0rpx 0rpx;
        color: var(--benbenFontColor4);
    }

    .result_fd1_0_c1_c0 {
        color: #333333;
        font-size: 32rpx;
        font-weight: 400;
        line-height: 45rpx;
        margin: 0rpx 10rpx 0rpx 0rpx;
        text-align: center;
        font-style: normal;
    }

    .result_fd1_0_c0_c1 {
        width: 16rpx;
        height: 9rpx;
        margin: 0rpx 0rpx 0rpx 12rpx;
    }

    .result_fd1_0_c0_c0_1 {
        font-size: 32rpx;
        font-weight: 400;
        line-height: 45rpx;
        color: var(--benbenFontColor4);
    }

    .result_fd1_0_c0_c0 {
        color: #333333;
        font-size: 32rpx;
        font-weight: 400;
        line-height: 45rpx;
        text-align: center;
        font-style: normal;
    }

    .result_fd1_0_c0 {
        margin: 0rpx 0rpx 0rpx 0rpx;
    }

    .result_fd1_0 {
        padding: 0rpx 32rpx 0rpx 32rpx;
        font-size: 28rpx;
        font-weight: 400;
        line-height: 40rpx;
    }

    .result_flex_2 {
        padding: 24rpx 24rpx 0rpx 24rpx;
    }

    .result_fd2_0_c1_c3_c0_c2_c3 {
        color: #999999;
        font-size: 17rpx;
        font-weight: 400;
        line-height: 24rpx;
        text-decoration: line-through;
    }

    .result_fd2_0_c1_c3_c0_c2_c2 {
        color: #999999;
        font-size: 17rpx;
        font-weight: 400;
        line-height: 24rpx;
        margin: 0rpx 0rpx 0rpx 8rpx;
        text-decoration: line-through;
    }

    .result_fd2_0_c1_c3_c0_c2_c0 {
        color: #FF8E21;
        font-size: 22rpx;
        font-weight: 700;
        line-height: 30rpx;
    }

    .result_fd2_0_c1_c3_c0_c2 {
        margin: 12rpx 0rpx 0rpx 0rpx;
    }

    .result_fd2_0_c1_c3_c0_c1 {
        color: #333333;
        font-size: 18rpx;
        font-weight: 500;
        line-height: 24rpx;
        -webkit-line-clamp: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        margin: 12rpx 0rpx 0rpx 0rpx;
    }

    .result_fd2_0_c1_c3_c0_c0 {
        width: 144rpx;
        height: 144rpx;
        border-radius: 16rpx;
    }

    .result_fd2_0_c1_c3 {
        touch-action: none;
        width: 470rpx;
        margin: 24rpx 0rpx 0rpx 0rpx;
    }

    .result_fd2_0_c1_c2_c0_c0 {
        color: #FF3707;
        font-size: 20rpx;
        font-weight: 400;
        line-height: 28rpx;
        text-align: left;
        font-style: normal;
    }

    .result_fd2_0_c1_c2_c0 {
        border: 1px solid var(--benbenbdColor2);
        padding: 0rpx 15rpx 0rpx 15rpx;
        border-radius: 8rpx;
        height: 32rpx;
        line-height: 32rpx;
        margin: 0rpx 16rpx 0rpx 0rpx;
    }

    .result_fd2_0_c1_c2 {
        margin: 0rpx 24rpx 0rpx 0rpx;
    }

    .result_fd2_0_c1_c1_c4 {
        color: #666666;
        font-size: 24rpx;
        font-weight: 400;
        line-height: 33rpx;
        margin: 0rpx 0rpx 0rpx 20rpx;
    }

    .result_fd2_0_c1_c1_c3 {
        color: #666666;
        font-size: 24rpx;
        font-weight: 400;
        line-height: 33rpx;
    }

    .result_fd2_0_c1_c1_c2 {
        color: #666666;
        font-size: 24rpx;
        font-weight: 400;
        line-height: 33rpx;
        margin: 0rpx 0rpx 0rpx 16rpx;
    }

    .result_fd2_0_c1_c1_c1 {
        color: #FF5307;
        font-size: 24rpx;
        font-weight: 400;
        line-height: 33rpx;
    }

    .result_fd2_0_c1_c1_c0 {
        width: 20rpx;
        height: 20rpx;
    }

    .result_fd2_0_c1_c1 {
        margin: 0rpx 24rpx 16rpx 0rpx;
    }

    .result_fd2_0_c1_c0 {
        margin: 0rpx 24rpx 14rpx 0rpx;
        color: #333333;
        font-size: 32rpx;
        font-weight: 700;
        line-height: 45rpx;
    }

    .result_fd2_0_c0 {
        width: 180rpx;
        height: 180rpx;
        border-radius: 16rpx;
        margin: 0rpx 16rpx 0rpx 0rpx;
    }

    .result_fd2_0 {
        background: var(--benbenbgColor1);
        background-size: 100% auto;
        border-radius: 16rpx;
        padding: 20rpx 0rpx 32rpx 24rpx;
        margin: 0rpx 0rpx 24rpx 0rpx;
    }
</style>